package com.duan.calculator;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.GridView;

public class CalculatorActivity extends AppCompatActivity {

    //操作按钮
    private GridView mGridView = null;

    //输入框
    private EditText mEditInput = null;

    //适配器
    private ArrayAdapter mArrayAdapter= null;
    private final String[] mTextButtons = new String[]{
           "AC","(",")","÷",
            "7","8","9","×",
            "4","5","6","-",
            "1","2","3","+",
            "%","0",".","=",
    };


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //隐藏标题栏
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_calculator);

        mEditInput = (EditText)findViewById(R.id.edit_input);
        mGridView = (GridView)findViewById(R.id.grid_buttons);

        mArrayAdapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1,mTextButtons);
        mGridView.setAdapter(mArrayAdapter);

        // 禁止EditText从键盘输入
        mEditInput.setKeyListener(null);
    }
}
